package de.koller.worlders.engine.entity.enc;

import de.koller.oceanFramework.tree.Mother;
import de.koller.worlders.WSea;
import de.koller.worlders.engine.entity.enc.gu.GUMob;

public class EncSteering extends WSea {
	
	@Mother private EncRoot eroot;

	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
		
		if( !eroot.isEnabled() )
			return;
		
		moveMob();
	}
	
	private void moveMob() {
		GUMob g = eroot.getTargetedMob();
		if( g == null )
			return;
		
		if( !wroot.getInput().isMousePressed( 1 ) )
			return;
		
		int tx = wroot.getEntityContainer().getMouseWorldPosition().getXi();
		int ty = wroot.getEntityContainer().getMouseWorldPosition().getYi();
		
		g.movement.moveTo( tx, ty );
	}
	
}
